#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H

#include "Iview.h"

#ifdef __cplusplus
extern "C" {
#endif

class ViewManager
{
  public:

    /// Destructor
    __declspec(dllexport) ~ViewManager() {
      for(ViewVector::reverse_iterator It = m_Views.rbegin();
          It != m_Views.rend();
          ++It)
        delete *It;
    }

    /// Allows plugins to add new graphics drivers
    __declspec(dllexport) void addView(std::auto_ptr<IView> V) {
      m_Views.push_back(V.release());
    }

    /// Get the total number of registered graphics drivers
    __declspec(dllexport) size_t getViewCount() const {
      return m_Views.size();
    }
    /// Access a driver by its index
    __declspec(dllexport) IView &getView(size_t Index) {
      return *m_Views.at(Index);
    }

	__declspec(dllexport) void configAll(asIScriptEngine *engine)
	{
      for(ViewVector::reverse_iterator It = m_Views.rbegin();
          It != m_Views.rend();
          ++It)
	  {
		  (*It)->config(engine);
	  }
	}
  private:
    /// A vector of graphics drivers
    typedef std::vector<IView *> ViewVector;
    ViewVector m_Views; ///< All available graphics drivers
};

#ifdef __cplusplus
}
#endif

#endif